#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
   //FILE* fp=fopen("test.txt","w");
   //char s[]="linux so easy!";
   //fwrite(s,strlen(s),1,fp);
   //fclose(fp);

   //FILE* fp_read=fopen("test.txt","r");
   //char s_read[1024];
   //fread(s_read,1,1024,fp_read);
   //printf("%s\n",s_read);

   //return 0;
   
   int fd=open("test.txt",O_CREAT|O_WRONLY|O_TRUNC);
   char s[]="i like linux!";
   write(fd,s,strlen(s));
   close(fd);

   int fd_read=open("test.txt",O_RDONLY);
   char s_read[1024];
   read(fd_read,s_read,1024);
   printf("%s\n",s_read);


   return 0;
}
